﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Regions;
using EQual.Infrastructure;
namespace EQual.MainModule.Audits
{
    public class AuditsController : ModulesControllerBase<EQual .Infrastructure .MVPFramework .Views .IListView <object,object > ,DataAccesLayer .Audit >
    {

        IRegionManager _regionManager;

        public AuditsController(IRegionManager regionManager)
            : this()
        {
            this._regionManager = regionManager;
        }

        public AuditsController()
        {
            //this.AccesLayer = new DataAccesLayer.EmployeeDataAccesLayer();
            InitializeViews();
        }

        #region IModuleController Members

        public override void Run()
        {
            View.ItemAdded += new EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>>(View_ItemAdded);
            View.ItemSelected += new EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>>(View_ItemSelected);

            this._regionManager.RegisterViewWithRegion(RegionNames.MainRegion, () => this.View);
            this._regionManager.Regions[RegionNames.MainRegion].Activate(this.View);
        }

        void View_ItemSelected(object sender, Microsoft.Practices.Composite.Events.DataEventArgs<object> e)
        {

        }

        void View_ItemAdded(object sender, Microsoft.Practices.Composite.Events.DataEventArgs<object> e)
        {

        }

        #endregion

        public override void Dispaly(DataAccesLayer.Audit   item)
        {
            InjectViews();

            base.Dispaly(item);
        }

        EQual.MainModule.DetailsContainer containerView = new DetailsContainer();

        protected virtual void InjectViews()
        {
            //throw in to the datails region the datails view
            IRegion region = _regionManager.Regions[RegionNames.ActionRegion];

            if (!region.Views.Contains(containerView))
            {
               // containerView.AddView(GetDecoratedView(trainingPresenter.View, "Συμετέχοντες"));
              //  containerView.AddView(GetDecoratedView(detailsView, ""));

                region.Add(containerView);
            }

            //activate the current view
            region.Activate(containerView);
        }


    }
}
